package com.kingsoft.dc.khaos.listener

import com.kingsoft.dc.khaos.metadata.{TaskInfo}
import com.kingsoft.dc.khaos.scheduler.{ApplicationListener, ApplicationResult}
import org.apache.spark.scheduler.JobResult

/**
  * Created by chengguangqing on 2019/5/28.
  */
sealed trait KhaosListenerEvent


//application
case class KhaosListenerApplicationStart(applicationId:Int,
                                          submitTime:Long
                                         ) extends KhaosListenerEvent

case class KhaosListenerApplicationEnd(applicationId:Int,
                                       completedTime:Long,
                                       applicationResult: ApplicationResult
                                      ) extends KhaosListenerEvent

//job
case class KhaosListenerJobStart(jobId: Int,
                                  submitTime: Long,
                                  taskInfos: List[TaskInfo]
                                 ) extends KhaosListenerEvent {

  val taskIds = taskInfos.map(_.taskId)
}

case class KhaosListenerJobEnd(jobId:Int,
                                completedTime:Long,
                                jobResult:JobResult,
                                listener:ApplicationListener
                               ) extends KhaosListenerEvent

//task
case class KhaosListenerTaskStart(taskId:Int,
                                   moduleId:String,
                                   submitTime:Long,
                                   taskOpInfo: TaskInfo
                                  ) extends  KhaosListenerEvent

case class KhaosListenerTaskEnd(taskId:Int,
                                 moduleId:String,
                                 completedTime:Long
                                ) extends KhaosListenerEvent


